package com.maisuiit.io;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

/**
 * File类的基本用法
 * io流--缓冲字符流
 * BufferedReader类与BufferedWriter类
 */
public class IOTest6 {

    public static void main(String[] args) {
        BufferedReader br=null;
        BufferedWriter bw=null;
        try {
            //先创建FileReader对象
            FileReader fr=new FileReader("e:\\ff\\hsp.txt");
            br=new BufferedReader(fr);

            //创建FileWriter对象
            FileWriter fw=new FileWriter("e:\\hsp1.txt");
            bw=new BufferedWriter(fw);

            //循环读取
            String s="";
            while((s=br.readLine())!=null){
                //输出到磁盘
                bw.write(s+"\r\n");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            try {
                br.close();
                bw.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
